package exception;

public class TryCatchDemo {
    public static void main(String[] args) {
        System.out.println("程序开始");

       /* try{
            //String str = null;
            //System.out.println(str.length());

            //String str1 = "abcd";
            //System.out.println(str1.charAt(5));

            String str2 = "qwert";
            System.out.println(Integer.parseInt(str2));
        }catch (NullPointerException|StringIndexOutOfBoundsException e){
            System.out.println("空指针/下标越界");
        }catch(Exception e){
            System.out.println("异常");
        }
        System.out.println("程序结束");*/

        try {
            //String str1 = null;
            //System.out.println(str1.length());

            String str2 = "qwerty";
            System.out.println(str2.charAt(6));

            String str = "qwer";
            System.out.println(Integer.parseInt(str));
        } catch (NullPointerException|StringIndexOutOfBoundsException e) {
            System.out.println("空指针/下标越界");

        }catch(Exception e){
            System.out.println("其他异常");
        }
        System.out.println("程序结束");
    }
}
